/**
* Copyright (c) 2022 - present TinyVue Authors.
* Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
*
* Use of this source code is governed by an MIT-style license.
*
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*
*/

@import '../custom.less';
@import './vars.less';
@import '../motion/index.less';

@dialog-box-prefix-cls: ~'@{css-prefix}dialog-box';

.@{dialog-box-prefix-cls} {
  position: absolute;
  background: var(--tv-DialogBox-bg-color);
  border: 1px solid transparent;
  border-radius: var(--tv-DialogBox-border-radius);
  box-shadow: var(--tv-DialogBox-shadow);
  overflow: hidden;

  &__wrapper {
    .inject-DialogBox-vars();

    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    overflow: auto;
    margin: 0;
    display: block;
    align-items: normal;
  }

  &.is-fullscreen {
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
  }

  &.is-center {
    .@{dialog-box-prefix-cls}__header,
    .@{dialog-box-prefix-cls}__footer {
      text-align: center;
    }
  }

  &.is-fullscreen &__body {
    flex: 1;
    overflow: scroll;
    max-height: 100vh;
  }

  & &__header {
    padding: var(--tv-DialogBox-padding) var(--tv-DialogBox-padding) 24px;
    background: var(--tv-DialogBox-bg-color);
    font-weight: var(--tv-DialogBox-head-title-font-weight);
    display: flex;
    position: relative;
    justify-content: space-between;
    align-items: center;
    font-size: var(--tv-DialogBox-head-title-font-size);
    color: var(--tv-DialogBox-head-title-text-color);

    .@{dialog-box-prefix-cls}__title {
      flex: 1;
    }
    .@{dialog-box-prefix-cls}__btn-tools {
      display: flex;
      justify-content: space-between;
    }
    .@{dialog-box-prefix-cls}__headerbtn {
      position: relative;
      border: none;
      background: none;
      padding: 0;
      line-height: 1;
      top: -12px;
      right: -12px;
      cursor: pointer;

      & + .@{dialog-box-prefix-cls}__headerbtn {
        margin-left: 8px;
      }

      &:focus {
        outline: none; //解决chrome下,focus状态下蓝边问题
      }

      .@{dialog-box-prefix-cls}__close {
        fill: var(--tv-DialogBox-close-icon-color);
        font-size: var(--tv-DialogBox-close-icon-size);

        &:hover {
          fill: var(--tv-DialogBox-close-icon-color-hover);
        }
      }

      .@{dialog-box-prefix-cls}__resize {
        fill: var(--tv-DialogBox-resize-icon-color);
        font-size: var(--tv-DialogBox-resize-icon-size);

        &:hover {
          fill: var(--tv-DialogBox-resize-icon-color-hover);
        }
      }
    }
  }

  & &__body {
    text-align: left;
    padding: var(--tv-DialogBox-vertical-padding) var(--tv-DialogBox-padding);
    color: var(--tv-DialogBox-body-text-color);
    font-size: var(--tv-DialogBox-body-font-size);
    overflow: auto;
    max-height: 65vh;

    .@{css-prefix}upload {
      overflow: hidden;
    }

    > span {
      max-height: 120px;
      overflow-y: auto;
    }

    .@{css-prefix}dept__search {
      line-height: 30px;
    }
  }

  & &__footer {
    padding: 24px var(--tv-DialogBox-padding) var(--tv-DialogBox-padding);
    text-align: right;
    box-sizing: border-box;

    .@{css-prefix}button {
      min-width: var(--tv-DialogBox-footer-btn-min-width);
    }

    .@{css-prefix}toolbar {
      .@{css-prefix}button {
        margin: 0 4px;
      }
    }
  }

  // 抽屉
  &.is-right-slide {
    border-radius: 0;
    min-width: var(--tv-DialogBox-drawer-min-width);
    max-width: var(--tv-DialogBox-drawer-max-width);

    display: flex;
    flex-direction: column;

    .@{dialog-box-prefix-cls}__header,
    .@{dialog-box-prefix-cls}__footer {
      width: calc(100% - 64px);
      margin-left: var(--tv-DialogBox-padding);
      margin-right: var(--tv-DialogBox-padding);
    }

    .@{dialog-box-prefix-cls}__header {
      padding: var(--tv-DialogBox-padding) 0 24px;
      border-bottom: 1px solid var(--tv-DialogBox-head-divider-border-color);

      &btn {
        right: -16px;
      }
    }

    .@{dialog-box-prefix-cls}__body {
      flex: 1;
      overflow: auto;
      color: var(--tv-DialogBox-drawer-body-color);
      border-bottom: 1px solid var(--tv-DialogBox-drawer-divider-border-color);
      padding: var(--tv-DialogBox-vertical-padding) var(--tv-DialogBox-padding);
      max-height: 100vh;
    }

    .@{dialog-box-prefix-cls}__footer {
      padding: 24px 0 var(--tv-DialogBox-padding);
      text-align: right;
    }
  }
}

.dialog-box__scroll-lock {
  overflow: hidden;
}

.v-modal {
  .inject-DialogBox-vars();
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: var(--tv-DialogBox-mask-bg-color);
}

.v-modal-enter {
  animation: fade-in var(--tv-motion-fade-speed) ease;
}

.v-modal-leave {
  animation: fade-out var(--tv-motion-fade-speed) ease forwards;
}

.dialog-slideRight-enter-active {
  animation: slide-right-in var(--tv-motion-slide-speed) ease-in forwards;
}

.dialog-slideRight-leave-active {
  animation: slide-right-out var(--tv-motion-slide-speed) ease-in forwards;
}

.dialog-fade-enter-active {
  animation: fade-in-up var(--tv-motion-fade-speed);
}

.dialog-fade-leave-active {
  .@{dialog-box-prefix-cls} {
    animation: fade-out-up var(--tv-motion-fade-speed);
  }
  animation: fade-out-up var(--tv-motion-fade-speed);
}

.enlarge-enter-active {
  animation: enlarge-in var(--tv-motion-scale-speed) linear;
}

@media (max-width: 480px) {
  .@{dialog-box-prefix-cls} {
    width: 100% !important;
    top: 0 !important;
    left: 0 !important;
  }
}
